package com.naiterui.ehp.bs.patient.repository;

import java.util.Collection;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bp.domain.Department;

/**
 * <pre>
 * 科室信息持久化实现
 * </pre>
 *
 * @author fangguanhong
 * @date 2020/4/9 下午5:32
 * @since 1.0.0
 */
@Repository
public interface IApDepartmentRepository extends BaseJpaRepository<Department, Integer> {

    @Query("select d from Department d where d.parentId <> 0 and d.available = 1")
    List<Department> findAllByParentIdIsNotNull();

    @Override
    @Query("select d from Department d where d.available = 1")
    List<Department> findAll();

    List<Department> findByIdInAndAvailable(Collection<Integer> id, boolean available);

    List<Integer> findByParentIdAndAvailable(Integer parentId, boolean available);
}
